package com.gprcclient.convent;

import com.gprcclient.entity.GoodInfo;
import com.grpcclient.goods.GoodsInfo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: LCG
 * @date: 2022-10-26 14:23:53
 * @description:
 **/
@Mapper
@Component
public interface GoodInfoConvent {

    public static final GoodInfoConvent INSTANCE = Mappers.getMapper(GoodInfoConvent.class);

    @Mappings(
            {
                    @Mapping(target = "goodsId",expression = "java(goodsInfo.getGoodsId())"),
                    @Mapping(target = "goodsName",expression = "java(goodsInfo.getGoodsname())"),
                    @Mapping(target = "productName",expression = "java(goodsInfo.getProductname())")
            }
    )
    public GoodInfo toGoodInfo(GoodsInfo goodsInfo);

    /**
     * @author: LCG
     * @date: 2022-10-26 15:07:11
     * @description:  List 转换 list的时候可以通过 如上toGoodInfo 来转换list中的元素的每一个属性，
     * 因为在mapstruct中可以直接应用到如上toGoodInfo的转换
     */
    public List<GoodInfo> toGoodInfoList(List<GoodsInfo> list);



}
